home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_360 / uucp / uucp0.lzh / src / lib / setstdin.c < prev    next >
C/C++ Source or Header  |  1990-05-17  |  990b  |  47 lines

  1.  
  2. /*
  3.  *  SETSTDIN.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/lib/RCS/setstdin.c,v 1.1 90/02/02 12:08:28 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  8.  *
  9.  *  Sets stdin, stdout, and stderr to UUSER: handler
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include "config.h"
  14.  
  15. Prototype int SetStdin(int, char **);
  16.  
  17. int
  18. SetStdin(ac, av)
  19. int ac;
  20. char **av;
  21. {
  22.     short i;
  23.     short getty = 0;            /*  from getty    */
  24.     char *device = "serial.device";     /*  device name */
  25.     long unit = 0;            /*  unit no.    */
  26.     char buf[64];
  27.     FILE *f1, *f2, *f3;
  28.  
  29.     for (i = 1; i < ac; ++i) {
  30.     char *ptr = av[i];
  31.     if (*ptr != '-')
  32.         continue;
  33.     if (ptr[1] == 'D')
  34.         device = av[++i];
  35.     if (ptr[1] == 'U')
  36.         unit = atoi(av[++i]);
  37.     if (ptr[1] == 'G')
  38.         getty = 1;
  39.     }
  40.     sprintf(buf, "UUSER:%s/%d/R1000G%d", device, unit, getty);
  41.     f1 = freopen(buf, "r", stdin);
  42.     f2 = freopen(buf, "w+", stdout);
  43.     f3 = freopen(buf, "w+", stderr);
  44.     return(f1 && f2 && f3);
  45. }
  46.  
  47.